package com.heer.gymnasium.activity;

import android.content.Intent;
import android.util.Log;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

import com.heer.gymnasium.R;
import com.heer.gymnasium.util.ScreenUtils;
import com.heer.gymnasium.util.Session;

import butterknife.BindView;

/**
 * Created by heer on 17/3/28.
 */

public class SplashActivity extends BaseActivity {

    @BindView(R.id.image)
    ImageView image;

    Animation animation;

    @Override
    protected void init() {
        super.init();
        setContentView(R.layout.activity_splash);
        ScreenUtils.initScreen(this);
    }

    @Override
    protected void initView() {
        super.initView();

        animation = AnimationUtils.loadAnimation(this, R.anim.anim_splash);
        image.startAnimation(animation);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                Intent intent;
                if (Session.getUserIsLogin()) {
                    Log.e("sessid", Session.getUserId());
                    intent = new Intent(mContext, MainActivity.class);
                } else {
                    intent = new Intent(mContext, LoginActivity.class);
                }
                startActivity(intent);
                finish();
            }
        });
    }
}
